package com.uzai.console.web.tb.tbexclusiveplan;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.cms.base.CmsBaseInfoDto;
import com.uzai.console.dto.locallive.tlbtoken.TlbTokenQuery;
import com.uzai.console.dto.remoteapi.DirectionalGoodsQuery;
import com.uzai.console.dto.tb.tbexclusiveplan.TbExclusivePlanDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.locallive.TlbTokenService;
import com.uzai.console.service.tb.tbexclusiveolan.TbExclusivePlanService;
import com.uzai.console.vo.cms.base.CmsBaseInfoVo;
import com.uzai.console.vo.locallive.tlbtoken.TlbTokenInfoVo;
import com.uzai.console.vo.remoteapi.cps.DirectionalGoods;
import com.uzai.console.vo.tb.tbexclusiveplan.TbExclusivePlanVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 淘宝定向计划管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "定向计划",tags = "淘宝|定向计划")
@ApiSort(7)
@RestController
public class TbExclusivePlanController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(TbExclusivePlanController.class);

    @Autowired
    private TbExclusivePlanService tbExclusivePlanService;
    @Autowired
    private TlbTokenService tlbTokenService;

    @ApiOperation(value = "分页查询淘宝定向计划中显示的推老板定向商品列表", notes = "分页查询淘宝定向计划中显示的推老板定向商品列表", response = DirectionalGoods.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/tbExclusivePlan/tlbExclusiveGoods/findByPage")
    public Object findByPage(@RequestBody DirectionalGoodsQuery directionalGoodsQuery){
        return tbExclusivePlanService.findTlbTbExclusiveGoodsList(directionalGoodsQuery);
    }

    @ApiOperation(value = "查询淘宝定向计划信息", notes = "查询淘宝定向计划信息", response = TbExclusivePlanVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/tbExclusivePlan/findInfo")
    public Object findTbExclusivePlan(){
        return tbExclusivePlanService.findTbExclusivePlan(getLoginInfo().getMerId());
    }

    @SystemLogType(model = SystemModelEnum.TbExclusivePlan, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "保存淘宝定向计划信息", notes = "保存淘宝定向计划信息")
    @ApiOperationSupport(order = 3)
    @PostMapping("/tbExclusivePlan/update")
    public Object updateTbExclusivePlan(@RequestBody TbExclusivePlanDto tbExclusivePlanDto){
        tbExclusivePlanService.updateTbExclusivePlan(tbExclusivePlanDto);
        return true;
    }

    @ApiOperation(value = "分页查询推老板列表", notes = "分页查询推老板列表", response = TlbTokenInfoVo.class)
    @ApiOperationSupport(order = 4)
    @PostMapping("/tbExclusivePlan/findTlbTokenList")
    public Object findTlbTokenList(@RequestBody TlbTokenQuery tlbTokenQuery){
        return tlbTokenService.findTlbTokenListSelect(tlbTokenQuery);
    }

}
